﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace LedControl
{
    public partial class Form1 : Form
    {

        private void Case_Click(object sender, EventArgs e)
        {
            Button bt = (Button)sender;
            double[] Leds = new double[11];
            switch (bt.Text)
            {
                case "Case1-LED Verivide H":
                    Leds[0] = 158;
                    Leds[1] = 123;
                    Leds[2] = 0;
                    Leds[3] = 57;
                    Leds[4] = 0;
                    Leds[5] = 158;
                    Leds[6] = 132;
                    Leds[7] = 107;
                    Leds[8] = 104;
                    Leds[9] = 0;
                    Leds[10] = 157;
                    tbCCT.Text = "5315±50";
                    tbLuminance.Text = "70±1";
                    tbX.Text = "0.337±0.005";
                    tbY.Text = "0.350±0.005";
                    break;
                case "Case2-LED Verivide L":
                    Leds[0] = 121;
                    Leds[1] = 95;
                    Leds[2] = 0;
                    Leds[3] = 47;
                    Leds[4] = 0;
                    Leds[5] = 122;
                    Leds[6] = 107;
                    Leds[7] = 82;
                    Leds[8] = 80;
                    Leds[9] = 0;
                    Leds[10] = 121;
                    tbCCT.Text = "5385±50";
                    tbLuminance.Text = "35±1";
                    tbX.Text = "0.335±0.005";
                    tbY.Text = "0.343±0.005";
                    break;
                case "Case3-LED Tungsten H":
                    Leds[0] = 0;
                    Leds[1] = 118;
                    Leds[2] = 128;
                    Leds[3] = 84;
                    Leds[4] = 27;
                    Leds[5] = 182;
                    Leds[6] = 32;
                    Leds[7] = 0;
                    Leds[8] = 80;
                    Leds[9] = 52;
                    Leds[10] = 0;
                    tbCCT.Text = "2535±50";
                    tbLuminance.Text = "35±1";
                    tbX.Text = "0.474±0.005";
                    tbY.Text = "0.413±0.005";
                    break;
                case "Case4-LED Tungsten L":
                    Leds[0] = 0;
                    Leds[1] = 92;
                    Leds[2] = 91;
                    Leds[3] = 67;
                    Leds[4] = 0;
                    Leds[5] = 142;
                    Leds[6] = 29;
                    Leds[7] = 0;
                    Leds[8] = 70;
                    Leds[9] = 44;
                    Leds[10] = 0;
                    tbCCT.Text = "2460±50";
                    tbLuminance.Text = "17.5±1";
                    tbX.Text = "0.480±0.005";
                    tbY.Text = "0.413±0.005";
                    break;
                case "D65_HCRI":
                    Leds[0] = 210;
                    Leds[1] = 0;
                    Leds[2] = 0;
                    Leds[3] = 62;
                    Leds[4] = 0;
                    Leds[5] = 0;
                    Leds[6] = 105;
                    Leds[7] = 120;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT.Text = "5319";
                    tbLuminance.Text = "112";
                    tbX.Text = "0.337";
                    tbY.Text = "0.358";
                    break;
                case "D65_LCRI":
                    Leds[0] = 0;
                    Leds[1] = 50;
                    Leds[2] = 0;
                    Leds[3] = 0;
                    Leds[4] = 0;
                    Leds[5] = 0;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 210;
                    tbCCT.Text = "5358";
                    tbLuminance.Text = "109";
                    tbX.Text = "0.336";
                    tbY.Text = "0.3443";
                    break;
                case "case9":
                    Leds[0] = 10;
                    Leds[1] = 10;
                    Leds[2] = 10;
                    Leds[3] = 10;
                    Leds[4] = 10;
                    Leds[5] = 10;
                    Leds[6] = 10;
                    Leds[7] = 10;
                    Leds[8] = 10;
                    Leds[9] = 10;
                    Leds[10] = 10;
                    tbCCT.Text = "Null";
                    tbLuminance.Text = "Null";
                    tbX.Text = "Null";
                    tbY.Text = "Null";
                    break;
                case "Tun_HCRI":
                    Leds[0] = 0;
                    Leds[1] = 88;
                    Leds[2] = 156;
                    Leds[3] = 0;
                    Leds[4] = 0;
                    Leds[5] = 141;
                    Leds[6] = 43;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT.Text = "2583";
                    tbLuminance.Text = "53";
                    tbX.Text = "0.471";
                    tbY.Text = "0.415";
                    break;
                case "Tun_LCRI":
                    Leds[0] = 0;
                    Leds[1] = 150;
                    Leds[2] = 0;
                    Leds[3] = 0;
                    Leds[4] = 52;
                    Leds[5] = 0;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 143;
                    Leds[10] = 0;
                    tbCCT.Text = "2558";
                    tbLuminance.Text = "54";
                    tbX.Text = "0.473";
                    tbY.Text = "0.415";
                    break;
                case "Case10":
                    Leds[0] = 10;
                    Leds[1] = 10;
                    Leds[2] = 10;
                    Leds[3] = 10;
                    Leds[4] = 10;
                    Leds[5] = 10;
                    Leds[6] = 10;
                    Leds[7] = 10;
                    Leds[8] = 10;
                    Leds[9] = 10;
                    Leds[10] = 10;
                    tbCCT.Text = "Null";
                    tbLuminance.Text = "Null";
                    tbX.Text = "Null";
                    tbY.Text = "Null";
                    break;
                case "Case11":
                    Leds[0] = 10;
                    Leds[1] = 10;
                    Leds[2] = 10;
                    Leds[3] = 10;
                    Leds[4] = 10;
                    Leds[5] = 10;
                    Leds[6] = 10;
                    Leds[7] = 10;
                    Leds[8] = 10;
                    Leds[9] = 10;
                    Leds[10] = 10;
                    tbCCT.Text = "Null";
                    tbLuminance.Text = "Null";
                    tbX.Text = "Null";
                    tbY.Text = "Null";
                    break;
                case "Case12":
                    Leds[0] = 10;
                    Leds[1] = 10;
                    Leds[2] = 10;
                    Leds[3] = 10;
                    Leds[4] = 10;
                    Leds[5] = 10;
                    Leds[6] = 10;
                    Leds[7] = 10;
                    Leds[8] = 10;
                    Leds[9] = 10;
                    Leds[10] = 10;
                    tbCCT.Text = "Null";
                    tbLuminance.Text = "Null";
                    tbX.Text = "Null";
                    tbY.Text = "Null";
                    break;
            }
            drawPic.DrawScreen(Leds);
        }

        private void button17_Click(object sender, EventArgs e)
        {
            drawPic.DrawScreen(new double[11]);
            tp2NeutralCaseTimer.Enabled = false;
            textBox1.Text = "30";
            textBox1.ReadOnly = false;
        }

        int NeutralCaseTime;

        private void NeutralCase_Click(object sender, EventArgs e)
        {
            NeutralCaseTime = Convert.ToInt32(textBox1.Text);
            textBox1.ReadOnly = true;
            tp2NeutralCaseTimer.Enabled = true;
            double[] Leds = new double[11];
            Leds[0] = 152;
            Leds[1] = 99;
            Leds[2] = 78;
            Leds[3] = 0;
            Leds[4] = 54;
            Leds[5] = 166;
            Leds[6] = 107;
            Leds[7] = 107;
            Leds[8] = 70;
            Leds[9] = 0;
            Leds[10] = 94;
            tbCCT.Text = "5003±50";
            tbLuminance.Text = "50±1";
            tbX.Text = "0.346±0.005";
            tbY.Text = "0.359±0.005";
            drawPic.DrawScreen(Leds);
        }

        private void tp2NeutralCaseTimer_Tick(object sender, EventArgs e)
        {
            NeutralCaseTime--;
            textBox1.Text = NeutralCaseTime.ToString();
            if (NeutralCaseTime == 0)
            {
                textBox1.Text = "30";
                textBox1.ReadOnly = false;
                tp2NeutralCaseTimer.Enabled = false;
            }
        }
    }
}